
const { parseKeyword } = require('./pinyinUtil')



exports.filterByKeyword = function (plugins, keyword) {
    if (keyword == null) {
        return plugins
    }
    const retData = []
    for (let plugin of plugins) {
        const keywords = plugin.keyWords != undefined ? plugin.keyWords : parseKeyword(plugin.name)

        let status = false;
        for (let keyWord of keywords) {
            if (keyWord.toLocaleUpperCase().indexOf(keyword.toLocaleUpperCase()) >= 0) {
                status = true;
                retData.push(plugin)
                break
            }
        }
    }
    return retData
}
